﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CAGFIP.Jogo
{
    /* http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle */
    public static class Shuffler
    {
        static Random rng = new Random();

        /* Extension Method to List<T>*/
        public static List<T> Shuffle<T>(this List<T> list)
        {
            for (int i = list.Count; i > 1; i--)
            {
                int j = rng.Next(i);
                T tmp = list[j];
                list[j] = list[i - 1];
                list[i - 1] = tmp;
            }
            return list;
        }
    }
}
